//package cn.mesmile.security.config;
//
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerExceptionResolver;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.nio.file.AccessDeniedException;
//
///**
// * @author zb
// * @date 2020/4/5 23:31
// * @Description:
// */
//@Component
//public class HandlerControllerException implements HandlerExceptionResolver {
//
//    @Override
//    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
//        ModelAndView modelAndView = new ModelAndView();
//        /*
//         resp.setStatus(HttpServletResponse.SC_FORBIDDEN);
//        resp.setContentType("application/json;charset=UTF-8");
//        PrintWriter out = resp.getWriter();
//        out.write("{\"status\":\"error\",\"msg\":\"权限不足，请联系管理员!\"}");
//        out.flush();
//        out.close();
//         */
//        modelAndView.addObject("errorMsg",e.getMessage());
//        if(e instanceof AccessDeniedException){
//            System.out.println();
//            System.out.println("权限不足--------------------");

//            modelAndView.setViewName("redirect:/403.jsp");
//            System.out.println();
//        }
//        return modelAndView;
//    }
//
//
//}
